﻿' NOTE: If you change the class name "TyrrantUserService" here, you must also update the reference to "TyrrantUserService" in Web.config and in the associated .svc file.
Public Class TyranntUserService
    Implements ITyranntUserService

    Dim user As New UserRoutines

    Public Function GetUsers(ByVal token As String) As String Implements ITyranntUserService.GetUsers
        Return user.GetUserList(token)
    End Function

    Public Function Login(ByVal loginData As LoginType) As TokenType Implements ITyranntUserService.Login
        Dim aToken As New TokenType
        aToken.TokenString = user.Login(loginData.Username, loginData.Password)
        aToken.UserGroup = user.GetUserGroup(aToken.TokenString)
        aToken.UserAlias = user.GetUserAlias(aToken.TokenString)
        Return aToken
    End Function

    Public Function Logoff(ByVal token As String) As String Implements ITyranntUserService.Logout
        Return user.Logoff(token)
    End Function

    Public Function Register(ByVal registerData As RegisterType) As TokenType Implements ITyranntUserService.Register
        Dim aToken As New TokenType
        aToken.TokenString = user.register(registerData.Username, registerData.Password, registerData.UserAlias, registerData.Email)
        aToken.UserGroup = user.GetUserGroup(aToken.TokenString)
        aToken.UserAlias = user.GetUserAlias(aToken.TokenString)
        Return aToken
    End Function

    Public Function RemoveUser(ByVal token As String, ByVal userID As Integer) As String Implements ITyranntUserService.RemoveUser
        Return user.RemoveUser(token, userID)
    End Function

    Public Function GetUserGroup(ByVal token As String) As IntegerType Implements ITyranntUserService.GetUserGroup
        Return GetUserGroup(token)
    End Function

    Public Function ChangeUserGroup(ByVal token As String, ByVal userID As Integer, ByVal newGroup As Integer) As String Implements ITyranntUserService.ChangeUserGroup
        Return user.ChangeUserGroup(token, userID, newGroup)
    End Function

    Public Function SetMOTD(ByVal token As String, ByVal message As String) As String Implements ITyranntUserService.SetMOTD
        Return user.SetMOTD(token, message)
    End Function

    Public Function ChangePassword(ByVal token As String, ByVal userID As Integer, ByVal newPasword As String) As String Implements ITyranntUserService.ChangePassword
        Return user.ChangePassword(token, userID, newPasword)
    End Function
End Class
